package com.yidu.t299.service.ljc.impl;
import com.yidu.t299.dao.ljc.StoreroomMapper;
import com.yidu.t299.domain.ljc.Storeroom;
import com.yidu.t299.service.ljc.StoreroomBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

/**
 * @author 刘建常
 * @version 1.0
 * @description
 * @date:2023/3/10 10:33
 */
@Service
@Transactional
public class StoreroomBizImpl implements StoreroomBiz {
    @Autowired
    private StoreroomMapper storeroomMapper;

    @Override
    public int deleteByPrimaryKey(Integer outId) {
        return storeroomMapper.deleteByPrimaryKey(outId);
    }

    @Override
    public int insert(Storeroom record) {
        return storeroomMapper.insert(record);
    }

    @Override
    public Storeroom selectByPrimaryKey(Integer outId) {
        return storeroomMapper.selectByPrimaryKey(outId);
    }

    @Override
    public List<Storeroom> selectByPage(int rows, int page, String condition) {
        return storeroomMapper.selectByPage(rows, page, condition);
    }

    @Override
    public int selectCount(String condition) {
        return storeroomMapper.selectCount(condition);
    }

    @Override
    public int updateByPrimaryKey(Storeroom record) {
        return storeroomMapper.updateByPrimaryKey(record);
    }

    @Override
    public String getCondition(Storeroom record) {
        // 定义条件字符串变量，初始值为空格字符串
        String condition = " ";
        // 如果校区对象为空，则直接返回空条件字符串
        if (record == null) {
            return condition;
        }
        // 如果校区编号不为空(如果是基本类型就直接判断!=0)
        if (record.getOutId() != null) {
            condition += " and out_id = " + record.getOutId();
        }

        // 如果校区名称不为空
        if (record.getGoodsId() != null) {
            condition += " and goods_id like '%" + record.getGoodsId() + "%'";
        }

        if (record.getGoodsNumber() != null) {
            condition += " and goods_number like '%" + record.getGoodsNumber() + "%'";
        }

        if (record.getStockId() != null) {
            condition += " and stock_id like '%" + record.getStockId() + "%'";
        }

        if (record.getPullId() != null) {
            condition += " and pull_id like '%" + record.getPullId() + "%'";
        }

        if (record.getSchoolthing() != null && record.getSchoolthing().trim().length() != 0) {
            condition += " and schoolthing = " + record.getSchoolthing();
        }

        if (record.getBackState() != null && record.getBackState().trim().length() != 0) {
            condition += " and back_state like '%" + record.getBackState() + "%'";
        }
        // 返回条件字符串
        return condition;
    }
}
